package com.lu.wemedia.controller.v1;


import com.lu.minio.service.FileStorageService;
import com.lu.model.common.controller.BaseController;
import com.lu.model.common.dtos.ResponseResult;
import com.lu.model.wemedia.dto.WmMaterialDto;
import com.lu.wemedia.service.WmFileService;
import org.simpleframework.xml.Path;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 素材管理
 */


@RestController
@RequestMapping("/api/v1/material")
public class WmFileController extends BaseController{

    @Autowired
    private WmFileService wmFileService;



    /**
     * 上传图片
     * @param multipartFile
     * @return
     */
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) {
        return wmFileService.uploadPicture(multipartFile);
    }

    /**
     * 查询素材列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto dto) {
        return wmFileService.findList(dto);
    }


    /**
     * 删除图片
     * @param id
     * @return
     */
    @GetMapping("/del_picture/{id}")
    public ResponseResult remove(@PathVariable Integer id) {
        return toResponse(wmFileService.deleteById(id));
    }


    /**
     * 收藏图片
     * @param id
     * @return
     */
    @GetMapping("/collect/{id}")
    public ResponseResult collection(@PathVariable Integer id) {
        return toResponse(wmFileService.collection(id));
    }


    /**
     * 取消收藏图片
     * @param id
     * @return
     */
    @GetMapping("/cancel_collect/{id}")
    public ResponseResult noClooection(@PathVariable Integer id) {
        return ResponseResult.okResult(wmFileService.noCollection(id));
    }
}
